import * as Cesium from '@cesiumjs';


/* 312 */
/***/
(function(module, exports, __webpack_require__) {

  "use strict";

  Object.defineProperty(exports, "__esModule", {
    value: true
  });

  var _toConsumableArray2 = __webpack_require__(8);

  var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

  var _getPrototypeOf = __webpack_require__(3);

  var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

  var _classCallCheck2 = __webpack_require__(0);

  var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

  var _createClass2 = __webpack_require__(1);

  var _createClass3 = _interopRequireDefault(_createClass2);

  var _possibleConstructorReturn2 = __webpack_require__(4);

  var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

  var _get2 = __webpack_require__(6);

  var _get3 = _interopRequireDefault(_get2);

  var _inherits2 = __webpack_require__(5);

  var _inherits3 = _interopRequireDefault(_inherits2);

  var _mobx = __webpack_require__(2);

  var _bind = __webpack_require__(10);

  var _XbsjCzmObj2 = __webpack_require__(11);

  var _XbsjCzmObj3 = _interopRequireDefault(_XbsjCzmObj2);

  var _XbsjObject = __webpack_require__(9);

  var _XbsjObject2 = _interopRequireDefault(_XbsjObject);

  var _registerInteractionProperty = __webpack_require__(15);

  var _utils = __webpack_require__(80);

  var _utils2 = _interopRequireDefault(_utils);

  var _interpolate = __webpack_require__(161);

  var _CameraHelper = __webpack_require__(162);

  var _CameraHelper2 = _interopRequireDefault(_CameraHelper);

  var _Points = __webpack_require__(43);

  var _Points2 = _interopRequireDefault(_Points);

  var _Polyline = __webpack_require__(20);

  var _Polyline2 = _interopRequireDefault(_Polyline);

  function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
      default: obj
    };
  }

  var flyCartesian = void 0;

  var _updateCurrentPositionAndRotation_anotherPos = void 0;

  function computeRotationAlongThePath(d, currentPos, ds, length, positions, currentRotation) {
    _updateCurrentPositionAndRotation_anotherPos = _updateCurrentPositionAndRotation_anotherPos || [0, 0, 0];
    var anotherPos = _updateCurrentPositionAndRotation_anotherPos;
    var firstPos = void 0;
    var nextPos = void 0;
    var nextD = d + 0.01;
    if (nextD > length) {
      nextD = d - 0.01;
      if (nextD >= 0) {
        (0, _interpolate.interpolatePosition)(nextD, ds, positions, anotherPos);
        firstPos = anotherPos;
        nextPos = currentPos;
      }
    } else {
      (0, _interpolate.interpolatePosition)(nextD, ds, positions, anotherPos);
      firstPos = currentPos;
      nextPos = anotherPos;
    }

    if (firstPos && nextPos) {
      _utils2.default.Math.hpr(firstPos, nextPos, currentRotation);
      currentRotation[0] += Math.PI * 0.5;
    }

    return currentRotation;
  }

  /**
   * 路径
   * @memberof Obj
   * @class
   * @extends XbsjCzmObj
   */

  var Path = function(_XbsjCzmObj) {
    (0, _inherits3.default)(Path, _XbsjCzmObj);

    function Path(earth, guid) {
      (0, _classCallCheck3.default)(this, Path);

      var _this = (0, _possibleConstructorReturn3.default)(this, (Path.__proto__ || (0, _getPrototypeOf2
        .default)(Path)).call(this, earth, guid));

      _this._polyline = new _Polyline2.default(earth);
      _this.disposers.push(function() {
        return _this._polyline.destroy();
      });
      _this.disposers.push((0, _bind.track)(_this._polyline, 'positions', _this, 'positions'));
      _this.disposers.push((0, _bind.track)(_this._polyline, 'loop', _this, 'loop'));

      _this._polyline.show = _this.enabled && _this.show && _this.showHelper;
      _this.disposers.push((0, _mobx.reaction)(function() {
        return _this.enabled && _this.show && _this.showHelper;
      }, function(show) {
        _this._polyline.show = show;
        _this._polyline.showHelper = show;
      }));

      /**
       * 是否处于创建状态<br/>
       * 设置为true以后，将进入重新创建的状态；此时可以使用鼠标左键在三维窗口中点击来创建路径的关键点，当点击鼠标右键，则表示创建完成。此时该属性会自动变成false。
       * @type {boolean}
       * @instance
       * @default false
       * @name creating
       * @memberof Obj.Path
       */
      _this.disposers.push((0, _registerInteractionProperty.registerPolylineCreating)(_this._earth, _this, {
        polylineCreatingProperty: 'creating'
      }));

      /**
       * 是否处于编辑状态<br/>
       * 设置为true以后，将进入重新创建的状态；此时可以使用鼠标左键在三维窗口中选取需要修改路径的关键点，当点击鼠标右键，则表示编辑完成。此时该属性会自动变成false。
       * @type {boolean}
       * @instance
       * @default false
       * @name editing
       * @memberof Obj.Path
       */
      _this.disposers.push((0, _registerInteractionProperty.registerPolylineEditing)(_this._earth, _this, {
        polylineEditingProperty: 'editing'
      }));

      _this._cameras = [];
      _this.disposers.push(function() {
        // this._cameras.forEach(e => destroyCamera(e, this._earth));
        _this._cameras.forEach(function(e) {
          return e.destroy();
        });
        _this._cameras.length = 0;
      });

      // 这是为了防止positions被换成新的数组，从而导致下面的observe失效！
      _this.disposers.push((0, _mobx.intercept)(_this, 'rotations', function(changed) {
        if (changed.type === 'update') {
          var _this$rotations;

          (_this$rotations = _this.rotations).splice.apply(_this$rotations, [0, _this.rotations.length]
            .concat((0, _toConsumableArray3.default)(changed.newValue)));
        }

        return null;
      }));

      _this.disposers.push((0, _mobx.intercept)(_this.rotations, function(changed) {
        if (changed.type === 'splice') {
          var _this$_cameras;

          for (var i = changed.index; i < changed.index + changed.removedCount; ++i) {
            // destroyCamera(this._cameras[i], this._earth);
            _this._cameras[i].destroy();
          }
          var cameras = changed.added.map(function() {
            // const camera = createCamera(this._earth);
            // return camera;
            return new _CameraHelper2.default(_this._earth);
          });
          (_this$_cameras = _this._cameras).splice.apply(_this$_cameras, [changed.index, changed
            .removedCount
          ].concat((0, _toConsumableArray3.default)(cameras)));
        }

        return changed;
      }));

      _this.disposers.push((0, _mobx.reaction)(function() {
        return {
          positions: [].concat((0, _toConsumableArray3.default)(_this.positions.map(function(e) {
            return [].concat((0, _toConsumableArray3.default)(e));
          }))),
          rotations: [].concat((0, _toConsumableArray3.default)(_this.rotations.map(function(e) {
            return [].concat((0, _toConsumableArray3.default)(e));
          }))),
          show: _this.enabled && _this.show && _this.showDirection
        };
      }, function() {
        // 中间状态positions增加了，rotations还没增加上
        if (_this.positions.length !== _this.rotations.length) {
          return;
        }
        for (var i = 0; i < _this.positions.length; ++i) {
          var rotation = _this.rotations[i];
          var position = _this.positions[i];
          _this._cameras[i].position = position;
          _this._cameras[i].rotation = rotation;
        }

        var show = _this.enabled && _this.show && _this.showDirection;
        _this._cameras.forEach(function(camera) {
          return camera.show = show;
        });
      }));

      _this._curve = new _Polyline2.default(earth);
      _this._curve.arcType = 'NONE';
      _this._curve.show = _this.enabled && _this.show;
      _this.disposers.push(function() {
        return _this._curve = _this._curve && _this._curve.destroy();
      });
      _this.disposers.push((0, _mobx.reaction)(function() {
        return _this.enabled && _this.show;
      }, function(show) {
        _this._curve.show = show;
      }));

      (0, _mobx.extendObservable)(_this, {
        /**
         * 当前步进距离<br/>
         * 指当前播放状态下由第一个关键点沿路径运动到当前位置的长度，单位是米。<br/>
         * 当前playing属性为false时，此属性恒定不变；当playing为true，此属性会自动增加。
         * 随着currentD的变化，会实时计算currentPosition、currentRotation这两个属性。
         * currentPosition指当前位置，currentRotation指当前姿态
         * @type {number}
         * @instance
         * @default 0
         * @memberof Obj.Path
         */
        currentD: 0,
        /**
         * 当前相机是否可见<br/>
         * 当前相机指位于currentPosition处的一个相机。<br/>
         * 此属性，主要用来显示当前播放的位置，方便调试。<br/>
         * 注意：当设置cameraAttached为true时，务必手动将此属性设置为false。否则相机绑定以后，会发现前方有一个物体遮挡整个画面！
         * @type {boolean}
         * @instance
         * @default false
         * @memberof Obj.Path
         */
        currentShow: false,
        /**
         * 当前播放速度，单位为米/秒。<br/>
         * 注意，此属性可以实时修改，修改后的速度立即生效，所以可以动态修改路径上物体的前进速度！
         * @type {number}
         * @instance
         * @default 50.0,
         * @memberof Obj.Path
         */
        // currentSpeed: 50.0,
        /**
         * 是否循环播放<br/>
         * 如果为false，则playing设置为true时，会从当前位置播放到最后一个关键点，并停止播放，此时playing属性会自动变成false。
         * 若此属性为true时，播放到最后一个关键点以后，将自动重第一个关键点继续播放。
         * @type {boolean}
         * @instance
         * @default false,
         * @memberof Obj.Path
         */
        // loopPlay: false,
        _currentPosition: [0, 0, 0],
        _currentRotation: [0, 0, 0],
        /**
         * 当前相机位置，形式如：[0, 0, 0]<br/>
         * 该数组中的元素分别表示经度（单位弧度）、纬度（单位弧度）、高度（单位米）。
         * 注意该属性，为只读属性！
         * @type {number[]}
         * @instance
         * @readonly
         * @memberof Obj.Path
         */
        get currentPosition() {
          return this._currentPosition;
        },
        /**
         * 当前相机姿态，形式如：[0, 0, 0]<br/>
         * 该数组中的元素分别表示偏航角（单位弧度）、俯仰角（单位弧度）、翻转角（单位弧度）。
         * 注意该属性，为只读属性！
         * @type {number[]}
         * @instance
         * @readonly
         * @memberof Obj.Path
         */
        get currentRotation() {
          return this._currentRotation;
        }
      }, {
        currentPosition: _mobx.computed,
        currentRotation: _mobx.computed
      });
      // this.fromJsonFilterKeys.push('currentD', 'currentShow', 'currentSpeed');
      _this.fromJsonFilterKeys.push('currentD', 'currentShow');

      _this.disposers.push((0, _mobx.reaction)(function() {
        return {
          positions: [].concat((0, _toConsumableArray3.default)(_this.positions.map(function(e) {
            return [].concat((0, _toConsumableArray3.default)(e));
          }))),
          slices: _this.slices,
          loop: _this.loop
        };
      }, function() {
        var l = _this.positions.length;
        if (l < 3) {
          return;
        }
        (0, _interpolate.interpolatePositions)(_this.positions, _this.slices, _this.loop, _this._curve
          .positions);
      }));

      (0, _mobx.extendObservable)(_this, {
        _loopPositions: [],
        _loopRotations: [],
        _ds: [],
        get ds() {
          return this._ds;
        },
        /**
         * 当前路径的总长<br/>
         * 注意当loop设置true和false时，即使关键点没有变化，但是总长是会变化的。<br/>
         * 因为loop为true时，首末关键点会相连，这一段距离也会考虑到路径总长中。
         * @type {number[]}
         * @instance
         * @readonly
         * @memberof Obj.Path
         */
        get length() {
          if (this.loop && this._ds.length > 2) {
            return this._ds[this._ds.length - 2];
          } else {
            var d = this._ds.length === 0 ? 0 : this._ds[this._ds.length - 1];
            return d;
          }
        }
      }, {
        ds: _mobx.computed,
        length: _mobx.computed
      });

      _this.disposers.push((0, _mobx.reaction)(function() {
        return {
          cameraAttached: _this.cameraAttached,
          loop: _this.loop,
          positions: [].concat((0, _toConsumableArray3.default)(_this.positions.map(function(e) {
            return [].concat((0, _toConsumableArray3.default)(e));
          }))),
          rotations: [].concat((0, _toConsumableArray3.default)(_this.rotations.map(function(e) {
            return [].concat((0, _toConsumableArray3.default)(e));
          })))
        };
      }, function() {
        _this._updateCurrentPositionAndRotation();
      }, {
        delay: 100
      }));

      _this.disposers.push((0, _mobx.observe)(_this, 'currentD', function() {
        _this._updateCurrentPositionAndRotation();
      }));

      // this._currentCamera = createCamera(this._earth);
      _this._currentCamera = new _CameraHelper2.default(_this._earth);
      _this._currentPoints = new _Points2.default(_this._earth);
      _this.disposers.push(function() {
        _this._currentCamera = _this._currentCamera && _this._currentCamera.destroy();
        _this._currentPoints = _this._currentPoints && _this._currentPoints.destroy();
      });
      _this._currentPoints.points.push({});

      var updateCurrentCameraPositionAndRotation = function updateCurrentCameraPositionAndRotation() {
        var currentShow = _this.enabled && _this.currentShow;
        _this._currentCamera.show = currentShow;
        _this._currentPoints.show = currentShow;

        if (!currentShow) {
          return;
        }

        _this._currentPoints.points[0].position = [].concat((0, _toConsumableArray3.default)(_this
          .currentPosition));
        _this._currentCamera.position = _this.currentPosition;
        _this._currentCamera.rotation = _this.currentRotation;
      };

      _this.disposers.push((0, _mobx.reaction)(function() {
        return {
          show: _this.enabled && _this.currentShow,
          position: [].concat((0, _toConsumableArray3.default)(_this.currentPosition)),
          rotation: [].concat((0, _toConsumableArray3.default)(_this.currentRotation))
        };
      }, updateCurrentCameraPositionAndRotation));

      (0, _mobx.extendObservable)(_this, {
        _target: [0, 0, 0],
        _targetEnabled: false
      });

      _this.disposers.push((0, _mobx.reaction)(function() {
        return {
          _targetEnabled: _this._targetEnabled,
          _target: _this._target && [].concat((0, _toConsumableArray3.default)(_this._target)) ||
            undefined
        };
      }, function() {
        _this._targetEnabled && _this.targetTo(_this._target);
      }));

      /**
       * 是否处于指定所有关键点相机的目标的状态<br/>
       * 设置为true以后，所有关键点相机都会同时旋转，指向目标点。鼠标左键点击以后，该属性会自动变为false。
       * 注意：关键点相机状态需要开启showDirection属性以后，才能方便观察！
       * @type {boolean}
       * @instance
       * @default false
       * @name targetPicking
       * @memberof Obj.Path
       */
      _this.disposers.push((0, _registerInteractionProperty.registerPositionPicking)(_this._earth, _this, {
        positionPickingProperty: 'targetPicking',
        positionProperty: '_target'
      }));

      _this.disposers.push((0, _mobx.intercept)(_this, 'targetPicking', function(changed) {
        _this._targetEnabled = changed.newValue;
        return changed;
      }));

      /**
       * 是否处于播放状态<br/>
       * 如果属性值为true，则所有'current'开头的相关属性会动态发生变化。
       * 可以通过手动设置为false，来结束播放状态。
       * 当loopPlay属性为false时，playing属性会在路径播放到最后一个关键点的位置时，自动变为false。
       * @type {boolean}
       * @instance
       * @default false
       * @name playing
       * @memberof Obj.Path
       */
      (0, _mobx.extendObservable)(_this, {
        _pathPlayingListener: undefined,
        get playing() {
          return !!this._pathPlayingListener;
        },
        set playing(val) {
          if (!!val && !this._pathPlayingListener) {
            this._play();
          } else if (!val && this._pathPlayingListener) {
            this._pathPlayingListener = this._pathPlayingListener && this._pathPlayingListener();
          }
        }
      }, {
        _pathPlayingListener: _mobx.observable.ref,
        playing: _mobx.computed
      });

      _this.disposers.push(function() {
        _this.playing = false;
      });

      //     /**
      //      * 是否处于相机绑定状态<br/>
      //      * 当该属性为true时，当前相机会实时使用currentPosition属性指定位置，实时使用currentRotation属性来指定姿态。
      //      * 注意：当鼠标左键在三维窗口中点击时，会自动打断相机绑定状态，该属性会自动变为false。
      //      * @type {boolean}
      //      * @instance
      //      * @default false
      //      * @name cameraAttached
      //      * @memberof Obj.Path
      //      */    
      //     extendObservable(this, {
      //         _currentFlight: undefined,        
      //         get cameraAttached() {
      //             return !!this._currentFlight;
      //         },
      //         set cameraAttached(val) {
      //             const scene = this._earth.czm.scene;

      //             if (!!val && !this._currentFlight) {
      //                 this._currentFlight = {
      //                     cancelTween: () => {
      //                         this._currentFlight = undefined;
      //                     }
      //                 };
      //                 scene.camera.cancelFlight();
      //                 scene.camera._currentFlight = this._currentFlight;
      //             } else if (!val && this._currentFlight) {
      //                 if (this._currentFlight !== scene.camera._currentFlight) {
      //                     throw new Error('this._currentCamera !== scene.camera._currentFlight');
      //                 }
      //                 scene.camera.cancelFlight();
      //                 this._currentFlight = undefined;
      //             }
      //         }
      //     }, {
      //         _currentFlight: observable.ref,
      //         cameraAttached: computed,
      //     });

      //     this.disposers.push(() => {
      //         this.cameraAttached = false;
      //     });

      // cameraAttached
      _this.disposers.push((0, _registerInteractionProperty.registerCameraTracking)(_this._earth, _this, {
        cameraAttachedFunc: function cameraAttachedFunc(tracking) {
          var _this2 = this;

          var disposers = [];
          disposers.push((0, _mobx.reaction)(function() {
            return {
              currentPosition: [].concat((0, _toConsumableArray3.default)(_this2
                .currentPosition)),
              currentRotation: [].concat((0, _toConsumableArray3.default)(_this2
                .currentRotation)),
              cameraAttachedOffsetPosition: [].concat((0, _toConsumableArray3.default)(_this2
                .cameraAttachedOffsetPosition)),
              cameraAttachedOffsetRotation: [].concat((0, _toConsumableArray3.default)(_this2
                .cameraAttachedOffsetRotation)),
              viewDistance: _this2.viewDistance
            };
          }, function(prv) {
            for (var i = 0; i < 3; ++i) {
              tracking.position[i] = prv.currentPosition[i] + prv.cameraAttachedOffsetPosition[i];
              tracking.rotation[i] = prv.currentRotation[i] + prv.cameraAttachedOffsetRotation[i];
            }
            tracking.viewDistance = prv.viewDistance;
          }));
          this._earth.camera.tracking.isCameraLike = true;
          return function() {
            disposers.forEach(function(d) {
              return d();
            });
            disposers.length = 0;
          };
        }
      }));
      return _this;
    }



    (0, _createClass3.default)(Path, [{
      key: '_updateCurrentPositionAndRotation',
      value: function _updateCurrentPositionAndRotation() {
        var d = this.currentD;
        this._ds = (0, _interpolate.computDs)(this.positions, this.rotations, this.loop, this._ds, this
          ._loopPositions, this._loopRotations);
        var positions = this.loop ? this._loopPositions : this.positions;
        var rotations = this.loop ? this._loopRotations : this.rotations;
        (0, _interpolate.interpolatePosition)(d, this._ds, positions, this._currentPosition);

        if (!this.alwaysAlongThePath) {
          (0, _interpolate.interpolateRotation)(d, this._ds, rotations, this._currentRotation);
        } else {
          computeRotationAlongThePath(d, this._currentPosition, this._ds, this.length, positions, this
            ._currentRotation);
        }

        // if (this.cameraAttached) {
        //     this.currentCameraApply();
        // }
      }

      /**
       * 同时给所有关键点增加高度
       * @param {number} height 高度，单位米 
       */

    }, {
      key: 'addHeight',
      value: function addHeight(height) {
        this.positions.forEach(function(e) {
          return e[2] += height;
        });
      }

      /**
       * 将所有关键点的方向指向target所在位置
       * @param {number[]} target 用来表示观察位置，包含三个元素的数组，分别表示经度、纬度、高度 
       * @param {number[]} includeIndex 索引数组，如果有值，则指只处理includeIndex有的索引，如果无值，则全部处理
       */

    }, {
      key: 'targetTo',
      value: function targetTo(target, includeIndex) {
        var _this3 = this;

        if (this.positions.length === this.rotations.length) {
          this.positions.forEach(function(e, i) {
            if (!includeIndex || ~includeIndex.indexOf(i)) {
              _utils2.default.Math.hpr(e, target, _this3.rotations[i]);
              _this3.rotations[i][0] += Cesium.Math.PI_OVER_TWO;
            }
          });
        }
      }

      /**
       * 自动延沿路径计算关键点的姿态<br/>
       * 注意：如果不设置参数，从修改所有关键点的姿态。<br/>
       * includeIndex是一个数组，囊括所有需要计算的关键点的索引。
       * @param {number[] | undefined} includeIndex 索引数组，如果有值，则指只处理includeIndex有的索引，如果无值，则全部处理
       */

    }, {
      key: 'directionAlongThePath',
      value: function directionAlongThePath(includeIndex) {
        // var l = this.positions.length;
        // for (let i=0; i<l-1; ++i) {
        //     if (!includeIndex || ~includeIndex.indexOf(i)) {
        //         Tool.Math.hpr(this.positions[i], this.positions[i+1], this.rotations[i]);
        //         this.rotations[i][0] += Cesium.Math.PI_OVER_TWO;     
        //     }
        // }

        // // 特殊处理最后一个索引
        // if (!includeIndex || !includeIndex.indexOf(l-1)) {
        //     if (this.loop) { // 如果是循环的话，求取和首点的方向
        //         Tool.Math.hpr(this.positions[l-1], this.positions[0], this.rotations[l-1]);
        //     } else {
        //         // 如果不是循环的，以最后两点连线的方向来定。
        //         Tool.Math.hpr(this.positions[l-2], this.positions[l-1], this.rotations[l-1]);
        //     }
        //     this.rotations[l-1][0] += Cesium.Math.PI_OVER_TWO;     
        //     computeRotationAlongThePath(this.ds[l-1], this.positions[l-1], this._ds, this.length, this.positions, this.rotations[l-1]);
        // }

        var l = this.positions.length;
        for (var i = 0; i < l; ++i) {
          if (!includeIndex || ~includeIndex.indexOf(i)) {
            var ii = i + (this.loop ? 1 : 0);
            var positions = this.loop ? this._loopPositions : this.positions;
            computeRotationAlongThePath(this._ds[ii], positions[ii], this._ds, this.length, positions,
              this.rotations[i]);
          }
        }
      }

      /**
       * 根据索引值为first和last的关键点的姿态，对first和last之间的关键点自动进行插值处理。<br/>
       * 这样操作，可以做到自动进行相机姿态的平滑。<br/>
       * 如果参数不写，则自动根据首末关键点的姿态插值中间所有关键点的姿态。<br/>
       * 注意：first务必小于last
       * @param {number | undefined} first 第一个索引 
       * @param {number | undefined} last 最后一个索引
       */

    }, {
      key: 'directionLerpBetween',
      value: function directionLerpBetween() {
        var first = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
        var last = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;

        if (last === -1) {
          last = this.positions.length - 1;
        }

        if (last < first) {
          console.warn('directionLerpBetween 参数错误！');
          return;
        }

        this.directionLerpBetween_scratchDs = [];
        (0, _interpolate.computDs)(this.positions, this.rotations, false, this
          .directionLerpBetween_scratchDs);

        var ds = [this._ds[first], this._ds[last]];
        var rots = [this.rotations[first], this.rotations[last]];

        for (var i = first + 1; i < last; ++i) {
          (0, _interpolate.interpolateRotation)(this._ds[i], ds, rots, this.rotations[i]);
        }
      }
    }, {
      key: 'flyTo',
      value: function flyTo() {
        this._polyline.flyTo();
      }
    }, {
      key: 'currentCameraApply',

      /**
       * 应用当前相机姿态<br/>
       * 将该路径的currentPosition和currentRotation设置为相机的position和rotation。
       */
      value: function currentCameraApply() {
        var _Cesium$Cartesian;

        flyCartesian = flyCartesian || new Cesium.Cartesian3();
        var scene = this._earth.czm.scene;

        (_Cesium$Cartesian = Cesium.Cartesian3).fromRadians.apply(_Cesium$Cartesian, (0,
          _toConsumableArray3.default)(this.currentPosition).concat([undefined, flyCartesian]));
        var camera = scene.camera;
        camera.setView({
          destination: flyCartesian,
          orientation: {
            heading: this.currentRotation[0],
            pitch: this.currentRotation[1],
            roll: this.currentRotation[2]
          }
        });
      }
    }, {
      key: '_play',
      value: function _play() {
        var _this4 = this;

        var scene = this._earth.czm.scene;

        // 如果位于末端，则从头开始
        if (this.currentSpeed > 0 && this.currentD === this.length) {
          this.currentD = 0;
        }

        // 如果倒速播放，则从尾开始
        if (this.currentSpeed < 0 && this.currentD === 0) {
          this.currentD = this.length;
        }

        var lastTime = Date.now();
        this._pathPlayingListener = scene.postUpdate.addEventListener(function(scene, time) {
          var currentTime = Date.now();
          var diffTime = currentTime - lastTime;
          lastTime = currentTime;

          if (_this4.currentSpeed > 0) {
            // currentSpeed>0时，往前走
            var currentD = _this4.currentD + diffTime * 0.001 * _this4.currentSpeed;
            if (_this4.loopPlay) {
              if (currentD > _this4.length) {
                _this4.currentD = 0;
              } else {
                _this4.currentD = currentD;
              }
            } else {
              if (currentD > _this4.length) {
                _this4.currentD = _this4.length;
                _this4._pathPlayingListener = _this4._pathPlayingListener && _this4
                  ._pathPlayingListener();
              } else {
                _this4.currentD = currentD;
              }
            }
          } else {
            // 考虑一下currentSpeed<0时的走法
            var _currentD = _this4.currentD + diffTime * 0.001 * _this4.currentSpeed;
            if (_this4.loopPlay) {
              // 如果循环播放的话
              if (_currentD < 0) {
                _this4.currentD = _this4.length;
              } else {
                _this4.currentD = _currentD;
              }
            } else {
              if (_currentD < 0) {
                // 播放到0就终止操作
                _this4.currentD = 0;
                _this4._pathPlayingListener = _this4._pathPlayingListener && _this4
                  ._pathPlayingListener();
              } else {
                _this4.currentD = _currentD;
              }
            }
          }
        });

        // scene.camera._currentFlight = {
        //     cancelTween: () => {
        //         updateCameraListener();
        //     }
        // }
      }
    }, {
      key: 'destroy',
      value: function destroy() {
        return (0, _get3.default)(Path.prototype.__proto__ || (0, _getPrototypeOf2.default)(Path
          .prototype), 'destroy', this).call(this);
      }
    }, {
      key: 'isCameraLike',
      get: function get() {
        return true;
      }
    }]);
    return Path;
  }(_XbsjCzmObj3.default);

  Path.defaultOptions = {
    positions: [],
    rotations: [],
    show: true,
    showHelper: false,
    showDirection: false,
    loop: false,
    slices: 100,
    alwaysAlongThePath: false,
    cameraAttachedOffsetPosition: [0, 0, 0],
    cameraAttachedOffsetRotation: [0, 0, 0],
    viewDistance: 0,
    currentSpeed: 50.0,
    loopPlay: false
  };

  var xbsjSchema = {
    title: "Path Property",
    type: "object",
    properties: {
      /**
       * 显示路径
       * @type {boolean}
       * @instance
       * @default true
       * @memberof Obj.Path
       */
      show: {
        type: "boolean",
        title: "显示路径",
        default: "true",
        description: '显示路径'
      },
      /**
       * 是否显示辅助线框
       * @type {boolean}
       * @instance
       * @default false
       * @memberof Obj.Path
       */
      showHelper: {
        type: "boolean",
        title: "辅助线框",
        default: "false",
        description: '辅助线框'
      },
      /**
       * 显示方向
       * @type {boolean}
       * @instance
       * @default true
       * @memberof Obj.Path
       */
      showDirection: {
        type: "boolean",
        title: "显示方向",
        default: "true",
        description: '显示方向'
      },
      /**
       * 是否为环线
       * @type {boolean}
       * @instance
       * @default false
       * @memberof Obj.Path
       */
      loop: {
        type: "boolean",
        title: "是否为环线",
        default: "false",
        description: '是否为环线'
      },
      /**
       * 曲线分段数
       * @type {number}
       * @instance
       * @default 100
       * @memberof Obj.Path
       */
      slices: {
        type: "number",
        title: "曲线分段数",
        default: "100",
        description: '曲线分段数'
      },
      /**
       * 始终沿着路径方向运动
       * @type {boolean}
       * @instance
       * @default false
       * @memberof Obj.Path
       */
      alwaysAlongThePath: {
        type: "boolean",
        title: "始终沿着路径方向运动",
        default: "false",
        description: '始终沿着路径方向运动'
      },
      /**
       * 当前播放速度，单位为米/秒。<br/>
       * 注意，此属性可以实时修改，修改后的速度立即生效，所以可以动态修改路径上物体的前进速度！
       * @type {number}
       * @instance
       * @default 50.0,
       * @memberof Obj.Path
       */
      currentSpeed: {
        type: "number",
        title: "当前播放速度，单位为米",
        default: 50.0,
        description: '当前播放速度，单位为米'
      },
      /**
       * 是否循环播放<br/>
       * 如果为false，则playing设置为true时，会从当前位置播放到最后一个关键点，并停止播放，此时playing属性会自动变成false。
       * 若此属性为true时，播放到最后一个关键点以后，将自动重第一个关键点继续播放。
       * @type {boolean}
       * @instance
       * @default false,
       * @memberof Obj.Path
       */
      loopPlay: {
        type: "boolean",
        title: "是否循环播放",
        default: "false",
        description: '是否循环播放'
      }
    }
  };

  Path.xbsjSchema = xbsjSchema;

  var xbsjClassification = [{
    name: {
      chinese: '通用',
      english: 'General'
    },
    properties: ['show', 'showHelper', 'showDirection', 'loop', 'slices', 'alwaysAlongThePath']
  }];

  Path.xbsjClassification = xbsjClassification;

  _XbsjObject2.default.registerType(Path, 'Path');

  exports.default = Path;

  /***/
})
